class_name PlayerStateMachine
extends GameplayStateMachine

@onready var player: Player = $"../"


func _on_setup() -> void:
	add_transition("PlayerWallState",GameplaySimpleTransition.new("GhostState", func(): return not player.player_state_checker.is_wall_detected, func(): pass))
	add_transition("PlayerWallState", GameplaySimpleTransition.new("GhostState", func(): return player.player_input_handler.cancel_climb_input, func(): player.global_position.x += -player.face_direction * 3))
	
	var ground_transition := GameplaySimpleTransition.new(
		"PlayerGroundState",
		func(): return player.player_state_checker.is_floor_detected,
		func(): pass
	)
	add_transition("GhostState", ground_transition)
	add_transition("PlayerWallState", ground_transition)
	add_transition("PlayerAirState", ground_transition)
	
	var air_transition := GameplaySimpleTransition.new(
		"PlayerAirState",
		func(): return not player.player_state_checker.is_floor_detected,
		func(): pass
	)
	add_transition("GhostState", air_transition)
	add_transition("PlayerGroundState", air_transition)

	var wall_transition := GameplaySimpleTransition.new(
		"PlayerWallState",
		func(): return player.player_state_checker.is_wall_detected,
		func(): pass
	)
	add_transition("PlayerAirState", wall_transition)
